<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>动态参数</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>

</head>
<body>
    <div id="app">
        <h1>Hello app!</h1>
        <!-- <router-link to="/foo/123">跳转到foo/123</router-link>
        <router-link to="/foo/456">跳转到foo/456</router-link> -->
        <router-view></router-view>
    </div>    
    <script>
        const Foo = {
            template:`
            <div>
                <p>{{$route.params.id}}</p>
            </div>`
        };
      
        const routes = [
            {
                // 把某种模式匹配到的所有路由，全都映射到同个组件
                // 在路径中：id接受动态参数，全部跳转同一个页面
                // 必须要有根/
                path:"/foo/:id",
                component:Foo
            }
        ];
        const router = new VueRouter({
            routes,
        })

        const app = new Vue({
            el:"#app",
            router,
        })



    </script>
</body>
</html>